import numpy as np
import cv2 as cv

mat = np.zeros((800, 300, 1), np.uint16)
mat_slope_i = np.zeros((800, 300, 1), np.uint16)
mat_slope = np.zeros((800, 300, 1))
mat_adj_x = np.ones((800, 300, 1), np.uint16) * 32768

slope = 0.6
slope_i = int(slope / 1.0 * 65535)
max_depth = 65535
max_value = 1.31
step_height = 0.18
step_height_i = int(step_height / max_value * max_depth)
scale = 10
for i in range(1, 8):
    mat[(400 - i * 30 - 30):(400 - i * 30), 20:280, 0] = step_height_i * (i - 1)
    mat_slope_i[(400 - i * 30 - 30):(400 - i * 30), 20:280, 0] = slope_i
    mat_slope[(400 - i * 30 - 30):(400 - i * 30), 20:280, 0] = slope
    for j in range(10):
        mat_adj_x[400 - i * 30 + 5 + j, 20:280, 0] = (j - 10) * scale + 32768
        mat_adj_x[400 - i * 30 - 5 + j, 20:280, 0] = j * scale + 32768
cv.imwrite('map.tiff', mat)
cv.imwrite('adj_x.tiff', mat_adj_x)

width = 40
mat_wz = mat.copy()
mat_wz = cv.blur(mat_wz, (1, width * 2))
mat_slope_i = cv.blur(mat_slope_i, (1, width * 2))
mat_slope = cv.blur(mat_slope, (1, width * 2))
mat_dy = np.ones((800, 300, 1), np.uint16) * 32768
mat_dx = - mat_slope / np.sqrt(mat_slope ** 2 + 1)
mat_dx = ((mat_dx * 0.5 + 0.5) * 65535).astype(np.uint16)
cv.imwrite('wz.tiff', mat_wz)
cv.imwrite('ws.tiff', mat_slope)
cv.imwrite('dy.tiff', mat_dy)
cv.imwrite('dx.tiff', mat_dx)
